<?php $this->load->view('header');?>

<div class="page-container">
    <?php $this->load->view('sidebar');?>
    <!-- BEGIN CONTENT -->
    <div class="page-content-wrapper">
        <div class="page-content">
            <?php $this->load->view('sale/_sub_nav');?>
            <div class="row">
                <div class="col-md-12">
                    <?php

                    $validationErrors = validation_errors();

                    if ($validationErrors) :
                    ?>

                    <!-- END PAGE HEADER-->

                    <div class="alert alert-warning fade in">
                        <a class="close" data-dismiss="alert">&times;</a>
                        <?php echo $validationErrors; ?>
                    </div>
                    <?php endif; ?>

                     <div class="admin-box">
                            <?php echo form_open($this->uri->uri_string(), array('class'=>'form-horizontal','role'=>'form')); ?>
                            <div class="form-body">
                                <h3 class="form-section">教育顾问建议及学生情况</h3>
                                <div class="form-group">
                                    <label class="control-label col-md-3" ><?php echo lang('clue_student_name_no'); ?><span class="required">*</span></label>
                                    <div class="col-md-5">
                                        <?php if(isset($track)):?>
                                        <input type="text" name="" id="student_name" readonly class="form-control" value="<?php echo isset($track) ? $track->student_name.'(D-'.sprintf('%06d',$track->student_id).')' : ''; ?>" />
                                        <input type="hidden" name="student_id" id="student_id" value="<?php echo set_value('student_id', isset($track) ? $track->student_id : ''); ?>">
                                        <?php else:?>
                                            <input type="text" class="form-control select2" id="track_clues" />
                                        <?php endif;?>
                                        <span class="help-block"></span>
                                    </div>
                                </div>

                                <div class="form-group<?php echo form_error('title') ? ' error' : ''; ?>">
                                    <label class="control-label col-md-3" ><?php echo lang('clue_track_title'); ?></label>
                                    <div class="col-md-5">
                                            <input type="text" name="title" id="title" class="form-control" value="<?php echo set_value('title', isset($track) ? $track->title : ''); ?>" />
                                        <span class="help-block"><?php echo form_error('title'); ?></span>
                                    </div>
                                </div>

                                <div class="form-group<?php echo form_error('track_wish') ? ' error' : ''; ?>">
                                    <label class="control-label col-md-3" ><?php echo lang('clue_trade_wish'); ?><span class="required">*</span></label>
                                    <div class="col-md-5">
                                        <select name="track_wish" id="track_wish" class="form-control" >
                                            <?php foreach(config_item('comm.trade_wish') as $key=>$value):?>
                                                <option value="<?php echo $key;?>" <?php echo set_select('track_wish', $key); ?>><?php echo $value;?></option>
                                            <?php endforeach;?>
                                        </select>
                                        <span class="help-block"><?php echo form_error('track_wish'); ?></span>
                                    </div>
                                </div>

                                <div class="form-group<?php echo form_error('track_result') ? ' error' : ''; ?>">
                                    <label class="control-label col-md-3" ><?php echo lang('clue_track_result'); ?><span class="required">*</span></label>
                                    <div class="col-md-5">
                                        <select class="form-control" name="track_result" id="track_result">
                                             <?php foreach(config_item('comm.track_result') as $key=>$value):?>
                                                <option value="<?php echo $key;?>" <?php echo set_select('track_result', $key); ?>><?php echo $value;?></option>
                                            <?php endforeach;?>
                                        </select>
                                        <span class="help-block"><?php echo form_error('track_result'); ?></span>
                                    </div>
                                </div>


                                <div class="form-group<?php echo form_error('track_date') ? ' error' : ''; ?>">
                                    <label class="control-label col-md-3" ><?php echo lang('clue_track_date'); ?><span class="required">*</span></label>
                                    <div class="col-md-5">
                                        <div class="input-group date date-picker">
                                            <input type="text" name="track_date" id="track_date" class="form-control" value="<?php echo set_value('track_date', isset($track) ? $track->track_date : ''); ?>" />
                                            <span class="input-group-btn">
                                                <button class="btn default" type="button"><i class="fa fa-calendar"></i></button>
                                            </span>
                                        </div>
                                        <span class="help-block"><?php echo form_error('track_date'); ?></span>
                                    </div>
                                </div>

                                <div class="form-group<?php echo form_error('next_track_date') ? ' error' : ''; ?>">
                                    <label class="control-label col-md-3" ><?php echo lang('clue_next_track_date'); ?></label>
                                    <div class="col-md-5">
                                        <div class="input-group date date-picker">
                                            <input type="text" name="next_track_date" id="track_next_date" class="form-control" value="<?php echo set_value('next_track_date', isset($track) ? $track->next_track_date : ''); ?>" />
                                            <span class="input-group-btn">
                                                <button class="btn default" type="button"><i class="fa fa-calendar"></i></button>
                                            </span>
                                        </div>
                                        <span class="help-block"><?php echo form_error('next_track_date'); ?></span>
                                    </div>
                                </div>

                                <div class="form-group<?php echo form_error('content') ? ' error' : ''; ?>">
                                    <label class="control-label col-md-3" ><?php echo lang('clue_track_content'); ?></label>
                                    <div class="col-md-5">
                                        <textarea name="content" class="form-control"><?php echo set_value('content', isset($track) ? $track->content : ''); ?></textarea>
                                        <span class="help-block"><?php echo form_error('content'); ?></span>
                                    </div>
                                </div>

                                 <div class="form-group<?php echo form_error('consultant') ? ' error' : ''; ?>">
                                    <label class="control-label col-md-3" ><?php echo lang('clue_consultant'); ?><span class="required">*</span></label>
                                    <div class="col-md-5">
                                        <select class="form-control" name="consultant" id="consultant">
                                                <?php if (isset($consultants) && is_array($consultants) && count($consultants)) :?>
                                                    <?php foreach ($consultants as $consultant) :?>
                                                         <option value="<?php echo $consultant['id']; ?>">
                                                            <?php echo $consultant['nickname']; ?>
                                                        </option>
                                                    <?php endforeach; ?>
                                                <?php else:?>
                                                    <option value="0">无</option>
                                                <?php endif;?>
                                        </select>
                                        <span class="help-block"><?php echo form_error('consultant'); ?></span>
                                    </div>
                                </div>

                            <div class="form-actions fluid">
                                <div class="row">
                                    <div class="col-md-6">
                                        <div class="col-md-offset-3 col-md-9">
                                            <button type="submit" class="btn green" name="save"><?php echo lang('action_save');?></button>
                                            <a href="<?php echo site_url('/sale/tracks');?>" class="btn default"><?php echo lang('action_cancel');?></a>
                                        </div>
                                    </div>
                                    <div class="col-md-6">
                                    </div>
                                </div>
                            </div>
                            <?php echo form_close(); ?>
                        </div>

  </div>
                    </div>
                </div>

            <?php $this->load->view('footer');?>

            <script>
                jQuery(document).ready(function() {
                    App.init(); // initlayout and core plugins
                });
            </script>

            </body>
            <!-- END BODY -->
            </html>
